﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WSAP
{
    public partial class FrameTestForm : Form
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public FrameTestForm()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 截面尺寸
        /// </summary>
        private double cDimension
        {
            get
            {
                return Convert.ToDouble(this.CDimensionTextbox.Text);
            }
        }

        /// <summary>
        /// 梁截面宽度
        /// </summary>
        private double beamWidth
        {
            get
            {
                return Convert.ToDouble(this.BeamWidthTextbox.Text);
            }
        }

        /// <summary>
        /// 梁截面高度
        /// </summary>
        private double beamHeight
        {
            get
            {
                return Convert.ToDouble(this.BeamHeightTextbox.Text);
            }
        }

        /// <summary>
        /// 层高
        /// </summary>
        private double storeyHeight
        {
            get
            {
                return Convert.ToDouble(this.StoreyHeightTextbox.Text);
            }
        }

        /// <summary>
        /// 跨度
        /// </summary>
        private double spanLength
        {
            get
            {
                return Convert.ToDouble(this.SpanLengthTextbox.Text);
            }
        }

        /// <summary>
        /// 构件长度
        /// </summary>
        private int storeyNum
        {
            get
            {
                return Convert.ToInt32(this.StoreyNumTextbox.Text);
            }
        }

        /// <summary>
        /// 跨数
        /// </summary>
        private int spanNum
        {
            get
            {
                return Convert.ToInt32(this.SpanNumTextbox.Text);
            }
        }

        /// <summary>
        /// 节点质量
        /// </summary>
        private double nodeMass
        {
            get
            {
                return Convert.ToDouble(this.NodeMassTextbox.Text);
            }
        }

        /// <summary>
        /// 模态分析数
        /// </summary>
        private int eigenNumber
        {
            get
            {
                return Convert.ToInt32(this.EigenNumberTextbox.Text);
            }
        }

        /// <summary>
        /// 水平力
        /// </summary>
        private double horizontalLoad
        {
            get
            {
                return Convert.ToDouble(this.HLoadTextobx.Text);
            }
        }

        /// <summary>
        /// 水平力
        /// </summary>
        private double verticalLoad
        {
            get
            {
                return Convert.ToDouble(this.VLoadTextobx.Text);
            }
        }

        /// <summary>
        /// 获得弹塑性模型
        /// </summary>
        /// <returns></returns>
        private WModelNet GetModel()
        {
            return WSAPFrame.GetWModelNet(this.cDimension, this.beamWidth, this.beamHeight,
                this.spanLength, this.storeyHeight, this.spanNum, this.storeyNum,
                this.BeamRigidEndCheckBox.Checked? Convert.ToDouble(this.BeamRigidEndTextbox.Text): 0);
        }
         
        /// <summary>
        /// 线性分析
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LAButton_Click(object sender, EventArgs e)
        {
            WSAPFrame.HorizontalLoadLinearAnalyzeExample(this.GetModel(), this.verticalLoad, this.horizontalLoad, this.StaticRadioButton.Checked);
        }

        /// <summary>
        /// 常规分析
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GAButton_Click(object sender, EventArgs e)
        {
            WSAPFrame.HorizontalLoadGeneralAnalyzeExample(this.GetModel(), this.verticalLoad, this.horizontalLoad, this.StaticRadioButton.Checked);
        }

        /// <summary>
        /// 模态分析按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EigenButton_Click(object sender, EventArgs e)
        {
            StructrueChart.ModeID = Convert.ToInt32(this.ModeShowTextbox.Text);
            StructrueChart.ModeID = StructrueChart.ModeID <= this.eigenNumber ?
                StructrueChart.ModeID : this.eigenNumber;
            WSAPFrame.EigenExample(this.GetModel(),
              this.nodeMass, this.eigenNumber, this.StaticRadioButton.Checked);
        }
    }
}
